<template>
  <div class="app-container">

    <div class="filter-container">

      <el-date-picker
        v-model="tradingDay"
        value-format="yyyy-MM-dd"
        type="date"
        class="filter-item"
      />
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
      >search
      </el-button>
    </div>
    <my-table
      :grid-table-header="tableHeard"
      :table-data="tableData"
      :clikc-cell="clickCell"
      @cellOnClick="cellClik"
    />
  </div>
</template>

<script>
import myTable from '@/components/Tables/index.vue'
import { api_account_names } from '@/api/pnl_analysis'

export default {
  components: { myTable },
  data() {
    return {
      tableData: [
        {
          'account_name': 'sim3',
          'trading_day': '2021/2/22',
          'delta_pnl': '-16189336.11',
          'market_value': 984144808.7,
          'delta_fee': 174078.6415,
          'eq_total_res_pnl': '-4602558.277',
          'eq_intraday_res_pnl': 161661.572,
          'eq_interday_res_pnl': '-4764219.7',
          'eq_total_fac_pnl': '-11586778.95',
          'eq_intraday_fac_pnl': 1497679.857,
          'eq_interday_fac_pnl': '-13084457.95'
        },
        {
          'account_name': 'sim3',
          'trading_day': '2021/2/22',
          'delta_pnl': '-16189336.11',
          'market_value': 984144808.7,
          'delta_fee': 174078.6415,
          'eq_total_res_pnl': '-4602558.277',
          'eq_intraday_res_pnl': 161661.572,
          'eq_interday_res_pnl': '-4764219.7',
          'eq_total_fac_pnl': '-11586778.95',
          'eq_intraday_fac_pnl': 1497679.857,
          'eq_interday_fac_pnl': '-13084457.95'
        },
        {
          'account_name': 'sim3',
          'trading_day': '2021/2/22',
          'delta_pnl': '-16189336.11',
          'market_value': 984144808.7,
          'delta_fee': 174078.6415,
          'eq_total_res_pnl': '-4602558.277',
          'eq_intraday_res_pnl': 161661.572,
          'eq_interday_res_pnl': '-4764219.7',
          'eq_total_fac_pnl': '-11586778.95',
          'eq_intraday_fac_pnl': 1497679.857,
          'eq_interday_fac_pnl': '-13084457.95'
        },
        {
          'account_name': 'sim3',
          'trading_day': '2021/2/22',
          'delta_pnl': '-16189336.11',
          'market_value': 984144808.7,
          'delta_fee': 174078.6415,
          'eq_total_res_pnl': '-4602558.277',
          'eq_intraday_res_pnl': 161661.572,
          'eq_interday_res_pnl': '-4764219.7',
          'eq_total_fac_pnl': '-11586778.95',
          'eq_intraday_fac_pnl': 1497679.857,
          'eq_interday_fac_pnl': '-13084457.95'
        },
        {
          'account_name': 'sim3',
          'trading_day': '2021/2/22',
          'delta_pnl': '-16189336.11',
          'market_value': 984144808.7,
          'delta_fee': 174078.6415,
          'eq_total_res_pnl': '-4602558.277',
          'eq_intraday_res_pnl': 161661.572,
          'eq_interday_res_pnl': '-4764219.7',
          'eq_total_fac_pnl': '-11586778.95',
          'eq_intraday_fac_pnl': 1497679.857,
          'eq_interday_fac_pnl': '-13084457.95'
        },
        {
          'account_name': 'sim1',
          'trading_day': '2021/2/22',
          'delta_pnl': '-12865838.28',
          'market_value': 988680811.5,
          'delta_fee': 157910.6787,
          'eq_total_res_pnl': '-4054831.458',
          'eq_intraday_res_pnl': 71967.69915,
          'eq_interday_res_pnl': '-4126799.001',
          'eq_total_fac_pnl': '-8811005.949',
          'eq_intraday_fac_pnl': 1254136.728,
          'eq_interday_fac_pnl': '-10065144.34'
        }
      ],
      tableHeard: {
        'account_name': '用户名',
        'trading_day': 'trading_day',
        'delta_pnl': 'delta_pnl',
        'market_value': 'market_value',
        'delta_fee': 'delta_fee',
        'eq_total_res_pnl': 'eq_total_res_pnl',
        'eq_intraday_res_pnl': 'eq_intraday_res_pnl',
        'eq_interday_res_pnl': 'eq_interday_res_pnl',
        'eq_total_fac_pnl': 'eq_total_fac_pnl',
        'eq_intraday_fac_pnl': 'eq_intraday_fac_pnl',
        'eq_interday_fac_pnl': 'eq_interday_fac_pnl'
      },
      clickCell: ['account_name'],
      tradingDay : new Date()
    }
  },
  methods: {
    get_account_names() {
      api_account_names(this.tradingDay)
        .then((response) => {
          // 请求数据这里换成所需要的接口
          // this.tableData = response.data


        })
        .catch((e) => {
          console.log(e)
        })
    },
    rowclik(row) {
      console.log(' rowClikc---callback----')
      console.log(row)
      console.log(row.name)
      console.log('跳转')
      this.$router.push({ name: 'demo', params: { account: '思达22号' }})
    },
    cellClik(row, column, cell, event) {
      console.log(' cellClik---callback----')
      // this.$router.push({ name: 'demo', params: { account: '思达22号' }})
      // console.log(column.label)
      //
      // // 这里做个异步请求
      // this.tableData3=this.tableData2
      console.log(column)
      console.log(cell)
      console.log(row)
      this.$router.push({ name: 'single', params: { account: row[column.property] }})
    }
  }
}
</script>

<style scoped>

</style>
